abort->fatal in more places.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 13 Sep 2002 23:17:11 +0000 (23:17 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 13 Sep 2002 23:17:11 +0000 (23:17 +0000)
gpsbabel/geo.c
gpsbabel/gpx.c
gpsbabel/mapsource.c
gpsbabel/mingw/testo [new file with mode: 0755]
gpsbabel/mkshort.c

index d7196b3d50b0daceba9cd1534d8814fd2c3a90ce..09a0c8d7ef540bb97f7ff6f695593ec217de44e4 100644 (file)
@@ -29,6 +29,8 @@ static waypoint *wpt_tmp;
 FILE *fd;
 FILE *ofd;
 
+#define MYNAME "geo"
+
 static void
 tag_coord(const char **attrv)
 {
@@ -134,12 +136,12 @@ geo_rd_init(const char *fname)
 {
        fd = fopen(fname, "r");
        if (fd == NULL) {
-               abort();
+               fatal(MYNAME ":Can not open %s for reading\n");
        }
 
        psr = XML_ParserCreate(NULL);
        if (!psr) {
-               abort();
+               fatal(MYNAME ":Can not create XML parser\n");
        }
 
        XML_SetElementHandler(psr, geo_start, geo_end);
@@ -157,7 +159,7 @@ geo_wr_init(const char *fname)
 {
        ofd = fopen(fname, "w");
        if (ofd == NULL) {
-               abort();
+               fatal(MYNAME ":Can not open %s for writing\n");
        }
 }
 
@@ -175,10 +177,9 @@ geo_read(void)
        
        while ((len = fread(buf, 1, sizeof(buf), fd))) {
                if (!XML_Parse(psr, buf, len, feof(fd))) {
-                       fprintf(stderr, "Parse error at %d: %s\n", 
+                       fatal(MYNAME ":Parse error at %d: %s\n", 
                                XML_GetCurrentLineNumber(psr),
                                XML_ErrorString(XML_GetErrorCode(psr)));
-                       exit(1);
                }
        }
        
index ff31881ffed11e876a80d122e3e7366e3ecf1cf3..58b84fefebf5e93e4757c870e13376d3bf545717 100644 (file)
@@ -212,7 +212,9 @@ gpx_waypt_pr(waypoint *waypointp)
        fprintf(ofd, "<wpt lat=\"%lf\" lon=\"%lf\">\n",
                waypointp->position.latitude.degrees,
                waypointp->position.longitude.degrees);
-       fprintf(ofd, "<name>%s</name>\n", waypointp->shortname);
+       fprintf(ofd, "<name>%s</name>\n", global_opts.synthesize_shortnames ?
+                                         mkshort(waypointp->description) : 
+                                         waypointp->shortname);
        fprintf(ofd, "<desc>");
        fprintf(ofd, "<![CDATA[%s]]>", waypointp->description);
        fprintf(ofd, "</desc>\n");
@@ -235,6 +237,7 @@ gpx_write(void)
 {
        fprintf(ofd, "<?xml version=\"1.0\"?>\n");
        fprintf(ofd, "<gpx\n\tversion=\"1.0\">\n");
+       setshort_length(32);
        waypt_disp_all(gpx_waypt_pr);
        fprintf(ofd, "</gpx>\n");
 }
index 446da142697e65526e7212d0375eab71ba209ee1..a1e7e7621e9392fb3c24b5b4cddb3cb13bb4cecf 100644 (file)
@@ -32,8 +32,7 @@ mapsource_rd_init(const char *fname)
 {
        mapsource_file_in = fopen(fname, "r");
        if (mapsource_file_in == NULL) {
-               fprintf(stderr, "Cannot open '%s' for reading\n", fname);
-               exit(1);
+               fatal("Cannot open '%s' for reading\n", fname);
        }
 }
 
@@ -48,7 +47,7 @@ mapsource_wr_init(const char *fname)
 {
        mapsource_file_out = fopen(fname, "w");
        if (mapsource_file_out == NULL) {
-               fprintf(stderr, "Cannot open '%s' for writing\n", fname);
+               fatal("Cannot open '%s' for writing\n", fname);
                exit(1);
        }
 }
diff --git a/gpsbabel/mingw/testo b/gpsbabel/mingw/testo
new file mode 100755 (executable)
index 0000000..e494f32
--- /dev/null
@@ -0,0 +1,56 @@
+PNAME="wine -- ./gpsbabel"
+
+# Geocaching .loc
+rm -f /tmp/gl.loc
+${PNAME} -i geo -f geocaching.loc -o geo -F /tmp/gl.loc
+diff /tmp/gl.loc ../reference
+
+# GPSUtil
+rm -f /tmp/gu.wpt
+${PNAME} -i geo -f geocaching.loc -o gpsutil -F /tmp/gu.wpt
+diff /tmp/gu.wpt ../reference
+
+# GPSman 
+rm -f /tmp/gm.gm /tmp/gm.gm+
+${PNAME} -i geo -f geocaching.loc -o gpsman -F /tmp/gm.gm
+${PNAME} -i gpsman -f /tmp/gm.gm -o gpsutil -F /tmp/gm.gm+
+diff /tmp/gm.gm+ /tmp/gu.wpt
+
+# GPX
+rm -f /tmp/gl.gpx /tmp/gpx.gpx
+${PNAME} -i geo -f geocaching.loc -o gpx -F /tmp/gl.gpx
+${PNAME} -i gpx -f /tmp/gl.gpx -o gpsutil -F /tmp/gpx.gpx
+diff /tmp/gpx.gpx /tmp/gu.wpt
+
+# Magellan Mapsend
+rm -f /tmp/mm.mapsend /tmp/mm.gps
+${PNAME} -i geo -f geocaching.loc -o mapsend -F /tmp/mm.mapsend
+${PNAME} -i mapsend -f /tmp/mm.mapsend -o gpsutil -F /tmp/mm.gps
+diff /tmp/mm.gps /tmp/gu.wpt
+
+# Garmin Mapsource
+rm -f /tmp/mm.mapsource /tmp/ms.gps
+#${PNAME} -i geo -f geocaching.loc -o mapsource -F /tmp/mm.mapsource
+#${PNAME} -i mapsource -f /tmp/mm.mapsource -o gpsutil -F /tmp/ms.gps
+# diff /tmp/ms.gps /tmp/gu.wpt
+
+# Magellan serial
+# TODO
+
+
+# CSV (Comma separated value) data.
+
+#${PNAME} -i geo -f geocaching.loc -o csv -F /tmp/csv.csv
+#${PNAME} -i csv -f /tmp/csv.csv -o gpsutil -F /tmp/csv2.csv
+#diff /tmp/csv2.csv /tmp/gu.wpt
+
+# PCX (Garmin mapsource import) file format
+rm -f /tmp/mm.pcx /tmp/pcx.gps
+${PNAME} -i geo -f geocaching.loc -o pcx -F /tmp/mm.pcx
+${PNAME} -i pcx -f /tmp/mm.pcx -o gpsutil -F /tmp/pcx.gps
+diff /tmp/mm.gps /tmp/gu.wpt
+
+# Magellan file format
+${PNAME} -i magellan -f ../reference/magfile -o magellan -F /tmp/magfile
+diff /tmp/magfile ../reference/magfile
+
index c943a0322ff3a72f750034b626e1805c7261f7e1..ffe954a45dfcfb49a50eb7b89176fd6986009065 100644 (file)
@@ -11,6 +11,8 @@ static int target_len = DEFAULT_TARGET_LEN;
 static const char *badchars = DEFAULT_BADCHARS;
 
 static int mustupper = 0;
+static const char needmem[] = 
+       "mkshort: could not reallocate memory for string\n";
 
 /*
  * This is the stuff that makes me ashamed to be a C programmer...
@@ -87,7 +89,7 @@ mkshort(char *istring)
 
 
        if (!ostring) {
-               abort();
+               fatal("mkshort: could not reallocate memory for string\n");
        }
 
        /* 
@@ -97,7 +99,7 @@ mkshort(char *istring)
            strncmp(ostring, "the ", 4) == 0) {
                nstring = strdup(ostring + 4);
                if (!nstring) {
-                       abort();
+                       fatal(needmem);
                }
                free(ostring);
                ostring = nstring;
@@ -124,7 +126,7 @@ mkshort(char *istring)
         */
        tstring = strdup(ostring);
        if (!tstring) {
-               abort();
+               fatal(needmem);
        }
        l = strlen (tstring);
        cp = ostring;
@@ -144,7 +146,7 @@ mkshort(char *istring)
         */
        tstring = strdup(ostring);
        if (!tstring) {
-               abort();
+               fatal(needmem);
        }
        l = strlen (tstring);
        cp = ostring;
@@ -169,7 +171,7 @@ mkshort(char *istring)
 
        tstring = strdup(ostring);
        if (!tstring) {
-               abort();
+               fatal(needmem);
        }
 
        /*